﻿using System;
using System.Collections;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KPIS.GERP.GBMS.BLL;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.MODEL;
using Telerik.Web.UI;


namespace KPIS.GERP.GBMS.APP_UI
{
    public enum RootNode
    {
        SourceType, Source, ExpenseGroup, Expense
    }

    public partial class TreeViewExpense : System.Web.UI.UserControl
    {
        private ISourceTypeBLL srcTypeCtrl = new SourceTypeBLL();
        private ISourceBLL srcCtrl = new SourceBLL();
        private IExpenseGroupBLL expGrpCtrl = new ExpenseGroupBLL();
        private IExpenseBLL expCtrl = new ExpenseBLL();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void LoadTreeView(RootNode root, bool hasCheckBoxChildNode)
        {
            tView.DataSource = GetTreeView(root);
            tView.DataBind();

           // tView.CheckChildNodes = hasCheckBoxChildNode;
        }

        private IList<TreeViewInfo> GetTreeView(RootNode root)
        {
            IList<TreeViewInfo> tvViewList = new List<TreeViewInfo>();

            switch (root)
            {
                //case RootNode.SourceType:
                //    {
                //        tvViewList = srcTypeCtrl.TreeView(tvViewList, true);
                //        tvViewList = srcCtrl.TreeView(tvViewList, false);
                //        tvViewList = expGrpCtrl.TreeView(tvViewList, false);
                //        tvViewList = expCtrl.TreeView(tvViewList, false, "");

                //        break;
                //    }
                //case RootNode.Source:
                //    {
                //        tvViewList = srcTypeCtrl.TreeView(tvViewList, true);
                //        tvViewList = srcCtrl.TreeView(tvViewList, false);
                //        tvViewList = expGrpCtrl.TreeView(tvViewList, false);
                //        tvViewList = expCtrl.TreeView(tvViewList, false, "");

                //        break;
                //    }
                case RootNode.ExpenseGroup:
                    {
                        tvViewList = expGrpCtrl.TreeView(tvViewList, true);
                        tvViewList = expCtrl.TreeView(tvViewList, false, "");

                        break;
                    }
                case RootNode.Expense:
                    {
                        tvViewList = expCtrl.TreeView(tvViewList, true, "");

                        break;
                    }
            }

            return tvViewList;
        }

        protected void tView_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
        }
    }
}